package com.xtkj.accountjava.base;

import lombok.Data;

@Data
public class Result {
    private int code;
    private String msg;
    private Object data;


    public Result(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    static public Result ok(String msg, Object data){
        return new Result(200,msg,data);
    }
    static public Result ok( Object data){
        return new Result(200,"操作成功",data);
    }
    static public Result okByMap( Object data){
        return new Result(200,"操作成功", new  BaseEntity(data));
    }
    static public Result error(int code,String msg, Object data){
        return new Result(code,msg,data);
    }
    static public Result error(String msg, Object data){
        return new Result(201,msg,data);
    }
    static public Result error(int code,String msg){
        return new Result(code,msg,null);
    }
    static public Result error( Object data){
        return new Result(201,"操作失败",data);
    }
    static public Result errorByMap( Object data){
        return new Result(201,"操作失败",new  BaseEntity(data));
    }
}
